// 2013-7-28上午11:54:00  net.betou.trade.main.manager.IntermediateProvidersAndAdministratorsMng.java

package net.betou.trade.main.manager;

import net.betou.common.page.Pagination;
import net.betou.common.security.exception.BadCredentialsException;
import net.betou.common.security.exception.UsernameNotFoundException;
import net.betou.trade.entity.main.AgentAndAdmins;
import net.betou.trade.entity.main.AgentAndAdminsExt;

/**
 * @deprecated
 * @author 叶装装
 */
public interface AgentAndAdminsMng{
	/**
	 * 更新居间管理员
	 * @param disabled
	 * @param password
	 * @param email
	 * @param mobile
	 * @param bean
	 * @param ext
	 * @param roleIds
	 * @return
	 */
	public AgentAndAdmins updateAgentAdmin( Boolean disabled, String password, String email, String mobile, AgentAndAdmins bean, AgentAndAdminsExt ext, Integer [] roleIds );
	
	/**
	 * 保存居间管理员
	 * @param currentAdmin
	 * @param ip
	 * @param roleIds
	 * @param bean
	 * @param ext
	 * @return
	 */
	public AgentAndAdmins saveAgentAdmin( AgentAndAdmins currentAdmin, String ip, Integer [ ] roleIds, AgentAndAdmins bean, AgentAndAdminsExt ext );
	
	/**
	 * 查找居间管理员
	 * @param admin
	 * @param searchProperty
	 * @param searchValue
	 * @param orderProperty
	 * @param orderDirection
	 * @param pageNo
	 * @param pageSize
	 * @param filterStatus
	 * @return
	 */
	public Pagination getAgentAdminPage( AgentAndAdmins admin, String searchProperty, String searchValue, String orderProperty, String orderDirection, int pageNo, int pageSize, String filterStatus );
	
	/**
	 * 更新居间商
	 * @param disabled
	 * @param password
	 * @param email
	 * @param mobile
	 * @param intermediaName
	 * @param bean
	 * @param ext
	 * @param roleIds
	 * @return
	 */
	public AgentAndAdmins updateAgency( Boolean disabled, String password, String email, String mobile, String intermediaName, AgentAndAdmins bean, AgentAndAdminsExt ext, Integer [] roleIds );
	
	/**
	 * 查找居间的管理员, system=false, justadmin=true
	 * @param id
	 * @return
	 */
	public AgentAndAdmins findAgentAdmin( Integer id );
	
	
	/**
	 * 查找居间商, 居间商的条件是： isSystem 为false。。justAdmin为false
	 * @param id
	 * @return
	 */
	public AgentAndAdmins findAgent( Integer id );
	
	
	
	/**
	 * 查找系统管理员, system=true, justadmin=true
	 * @param id
	 * @return
	 */
	public AgentAndAdmins findAdmin( Integer id );
	
	/**
	 * 保存居间商, 如果系统管理员,则添加顶级居间商
	 * @param agency  是否属于机构
	 * @param currentAdmin
	 * 					当前登录管理员
	 * @param ip
	 * @param roleIds
	 * @param bean
	 * @param ext
	 * @return
	 * @deprecated
	 */
	public AgentAndAdmins saveAgent( boolean agency, AgentAndAdmins currentAdmin, String ip, AgentAndAdmins bean, AgentAndAdminsExt ext );
	
	public AgentAndAdmins saveProxy( AgentAndAdmins currentAdmin, String ip, AgentAndAdmins bean, AgentAndAdminsExt ext );
	
	/**
	 * 添加机构
	 * @return
	 */
	public AgentAndAdmins saveAgency( AgentAndAdmins currentAdmin, String ip, AgentAndAdmins bean, AgentAndAdminsExt ext );
	
	
	/**
	 * 更新系统管理员
	 * @param disabled
	 * @param password
	 * @param email
	 * @param bean
	 * @param ext
	 * @param roleIds
	 * @return
	 */
	public AgentAndAdmins updateAdmin( Boolean disabled, String password, String email, AgentAndAdmins bean, AgentAndAdminsExt ext, Integer [ ] roleIds );
	
	
	/**
	 * 保存系统管理员
	 * @param ip
	 * @param roleIds
	 * @param bean
	 * @param ext
	 * @return
	 */
	public AgentAndAdmins saveAdmin( String ip, Integer [ ] roleIds, AgentAndAdmins bean, AgentAndAdminsExt ext );
	
	
	/**
	 * 查找自己的居间商
	 * @param id
	 * 				   当前的ID
	 * @param selfId
	 * 					自己的ID
	 * @return
	 */
	public AgentAndAdmins findMyAgent( Integer id, Integer selfId, Boolean system ); 
	
	/**
	 * 查找我的管理员
	 * @param id
	 * @param selfId
	 * @return
	 */
	public AgentAndAdmins findMyAgentAdmin( Integer id, Integer selfId, Boolean system );

	/**
	 * 根据ID查找
	 * @param id
	 * 				   ID
	 * @return
	 */
	public AgentAndAdmins findById( Integer id );

	/**
	 * 根据用户名查找
	 * @param username
	 * 				   用户名
	 * @return
	 */
	public AgentAndAdmins findByUsername( String username );
	
	/**
	 * 批量删除
	 * @param ids
	 * 				   传递的ID数组
	 * @return
	 */
	public AgentAndAdmins [ ] deleteByIds( Integer [ ] ids );
	
	/**
	 * 更新登录
	 * 
	 * @param userId
	 * @param ip
	 */
	public void updateLoginInfo( Integer userId, String ip );

	/**
	 * 登录
	 * 
	 * @param username
	 * @param password
	 * @param ip
	 * @return
	 * @throws UsernameNotFoundException
	 * @throws BadCredentialsException
	 */
	public AgentAndAdmins login( String username, String password, String ip ) throws UsernameNotFoundException, BadCredentialsException;

	/**
	 * 用户名是否存在
	 * 
	 * @param username
	 * @return
	 */
	public boolean userNameNotExist( String username );

	/**
	 * email 是否存在
	 * 
	 * @param email
	 * @return
	 */
	public boolean emailNotExist( String email );

	/**
	 * 手机号码是否存在
	 * 
	 * @param mobile
	 * @return
	 */
	public boolean mobileNotExist( String mobile );

	/**
	 * 居间商名称是否存在
	 * 
	 * @paramname
	 * @return
	 */
	public boolean nameNotExist( String name );


	/**
	 * 删除
	 * 
	 * @param id
	 * @return
	 */
	public AgentAndAdmins deleteById( Integer id );
	
	/**
	 * 查找代理商列表
	 * @return
	 */
	public Pagination getProxyPage( AgentAndAdmins user, String searchProperty, String searchValue, String orderProperty, String orderDirection, int pageNo, int pageSize, String filterStatus );
	
	/**
	 * 查找机构列表
	 * @return
	 */
	public Pagination getAgentPage( AgentAndAdmins user, String searchProperty, String searchValue, String orderProperty, String orderDirection, int pageNo, int pageSize, String filterStatus );
	
	/**
	 * 查找系统管理员
	 * @return
	 */
	public Pagination getAdminPage( String searchProperty, String searchValue, String orderProperty, String orderDirection, int pageNo, int pageSize, String filterStatus );
	
	
}
